<template>
  <div v-if="conList">
    <ConButton :checkItem="checkItem" @success="fetchData"></ConButton>
    <ConTable :conList="conList" @success="fetchData" @checkItem="checkItemchenge"></ConTable>
  </div>
  <div v-else>
    <van-empty description="数据请求失败！" />
  </div>
</template>

<script>
import ConTable from '@/components/container/ConTable'
import ConButton from '@/components/container/ConButton'
export default {
  data () {
    return {
      conList: null,
      checkItem: []
    }
  },
  mounted () {
    this.fetchData()
  },
  methods: {
    // 请求容器数据
    fetchData () {
      const parse = {
        data: {
          docker: 'curl --unix-socket /var/run/docker.sock -s "http:/v1.40/containers/json?all=true"'
        }
      }
      this.$post(parse, res => {
        this.conList = JSON.parse(res)
      })
    },
    // 处理选中的数据
    checkItemchenge (checkItem) {
      this.checkItem = checkItem
    }
  },
  components: {
    ConTable,
    ConButton
  }
}
</script>
